package com.kakarote.oa.service.impl;

import com.kakarote.core.servlet.BaseServiceImpl;
import com.kakarote.core.utils.UserUtil;
import com.kakarote.oa.entity.PO.OaLogTemplateConfigSort;
import com.kakarote.oa.mapper.OaLogTemplateConfigSortMapper;
import com.kakarote.oa.service.IOaLogTemplateConfigSortService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wanli
 * 针对表【wk_oa_log_template_sort(新建日志模板时个人排序)】的数据库操作Service实现
 * @date 2022-07-05 11:44:10
 */
@Service
public class OaLogTemplateConfigSortServiceImpl extends BaseServiceImpl<OaLogTemplateConfigSortMapper, OaLogTemplateConfigSort> implements IOaLogTemplateConfigSortService {

    @Override
    public void saveOrUpdateSort(List<OaLogTemplateConfigSort> sortList) {
        this.lambdaUpdate()
                .eq(OaLogTemplateConfigSort::getUserId, UserUtil.getUserId())
                .remove();
        for (int i = 0; i < sortList.size(); i++) {
            OaLogTemplateConfigSort sort = sortList.get(i);
            sort.setUserId(UserUtil.getUserId());
            sort.setSort(i);
        }
        this.saveBatch(sortList);
    }
}




